Fix bsr watcher leak - #873
Merged
Merged
Conversation
Signed-off-by: Jem Davies <jemsot@gmail.com>
Signed-off-by: Jem Davies <jemsot@gmail.com>
jem-davies
commented
Jun 1, 2026
gregfurman
reviewed
Jun 1, 2026
| } | ||
| multiModuleWatcher := &MultiModuleWatcher{} | ||
|
|
||
| ctx, cancel := context.WithCancel(context.Background()) |
Collaborator
There was a problem hiding this comment.
We shouldn't really be persisting ctx types. I think this should rather be a shutdown.Signaller that creates a new ctx.
e.g.
ctx, cancel := multiModuleWatcher.shutSig.SoftStopCtx(context.Background())|
|
||
| func (m *MultiModuleWatcher) Close() { | ||
| m.cancel() | ||
| for _, v := range m.bsrClients { |
Collaborator
There was a problem hiding this comment.
Q: Is it a memory leak that we never actually clear these clients stored in the map? Also, what if one stops before we call close -- should it be deleted early? 🤔
Collaborator
Author
There was a problem hiding this comment.
Added a m.bsrClients = nil - It should be ok to call Stop() multiple times.
| func (p *protobufProc) Close(context.Context) error { | ||
| func (p *protobufProc) Close(ctx context.Context) error { | ||
| if p.multiModuleWatcher != nil { | ||
| p.multiModuleWatcher.Close() |
Collaborator
There was a problem hiding this comment.
Should we be setting p.multiModuleWatcher = nil here?
Signed-off-by: Jem Davies <jemsot@gmail.com>
Signed-off-by: Jem Davies <jemsot@gmail.com>
Collaborator
Author
|
@gregfurman - thanks for review - I have responded / added commits to the code 🙏 |
Signed-off-by: Jem Davies <jemsot@gmail.com>
gregfurman
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So the "buf schema registry" poller appears to be leaking because it's context is not cancelled on Processor Close().
This PR adds 3 commits:
...
Previously I have been implementing the "lease" & "cache" option for this processor on #870 - however I think the issue of frequent calls to BSR services will likely be fixed with this PR.